﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class BookEntityConfig : IEntityTypeConfiguration<Book>
    {

        public void Configure(EntityTypeBuilder<Book> builder)
        {
            builder.ToTable("T_Books");
            builder.Property(e => e.Title)
                .HasMaxLength(50) // 长度约束
                .IsRequired() // 非空约束
                ;
            builder.Property(e => e.AuthorName)
                .HasMaxLength(20).IsRequired();
        }
    }
}
